/*
 * @Description:
 * @version:
 * @Author: sunqian_sr
 * @Date: 2022-10-10 13:52:52
 * @LastEditors: Andy
 * @LastEditTime: 2023-03-03 15:55:06
 */

import Vue from 'vue'
import { PiniaVuePlugin, setMapStoreSuffix } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import Element, { Message } from 'element-ui'
import VueContextMenu from 'vue-contextmenu'
import router from '@/common/router'

import directive from '@/common/directive' // directive
import pinia from '@/common/pinia'

import i18n from '@/common/lang'
import App from './App.vue'

import 'element-ui/lib/theme-chalk/index.css'
import '@/common/assets/style/index.scss'
import '@/common/assets/style/common.scss'
import '@package/components/src/bussines/icons/iconfont.css'
import './common/config/autoUiComponents.js'
import './permission'

Vue.config.productionTip = false
pinia.use(piniaPluginPersistedstate)
setMapStoreSuffix('_pinia')
Vue.use(PiniaVuePlugin)
Vue.use(VueContextMenu)
Vue.use(directive)
Vue.filter('emptyVal', (val) => {
  return (val = val || val === 0 ? val : '-')
})

const messages = ['success', 'warning', 'info', 'error']

messages.forEach((type) => {
  Element.Message[type] = (options) => {
    let resetOptions = options
    if (typeof resetOptions === 'string') {
      resetOptions = {
        message: resetOptions
      }
      resetOptions.duration = 1200
    }
    resetOptions.type = type
    return Element.Message(resetOptions)
  }
})
Vue.use(Element, { size: 'medium', zIndex: 3000 })

new Vue({
  router,
  pinia,
  i18n,
  render: (h) => h(App)
}).$mount('#app')
